{{! Client-side Mustache template for rendering the message edit form. }}

<form id="message_edit_form" class="form-horizontal new-style">
    <div class="alert" id="message-edit-send-status-{{message_id}}">
        <span class="send-status-close">&times;</span>
        <span class="error-msg"></span>
    </div>
    {{#if is_stream}}
    <div class="control-group no-margin">
        <div class="controls edit-controls">
            <div class="message_edit_header">
                <div class="stream_header_colorblock" {{#unless show_edit_stream}}style="display:none"{{/unless}}></div>
                <select class="select_edit_stream" id="select_stream_id_{{ message_id }}" {{#unless show_edit_stream}}style="display:none"{{/unless}}>
                    <option value="{{ stream_id }}" selected='selected'>#{{ stream_name }}</option>
                    {{#each available_streams}}
                    <option value="{{ this.stream_id }}">#{{this.name}}</option>
                    {{/each}}
                </select>
                <i class="fa fa-angle-right" aria-hidden="true" {{#unless show_edit_stream}}style="display:none"{{/unless}}></i>
                <input type="text" placeholder="{{topic}}" value="{{topic}}" class="message_edit_topic" id="message_edit_topic" />
                <div class="message_edit_breadcrumb_messages"  style='display:none;'>
                    <label class="checkbox">
                        <input class="send_notification_to_new_thread" name="send_notification_to_new_thread" type="checkbox" {{#if notify_new_thread}}checked="checked"{{/if}}>
                        <span></span>
                    </label>
                    <label for="send_notification_to_new_thread">{{t "Send notification to new topic" }}</label>
                    <div class="break-row"></div> <!-- break -->
                    <label class="checkbox">
                        <input class="send_notification_to_old_thread" name="send_notification_to_old_thread" type="checkbox" {{#if notify_old_thread}}checked="checked"{{/if}}>
                        <span></span>
                    </label>
                    <label for="send_notification_to_old_thread">{{t "Send notification to old topic" }}</label>
                </div>
                <select class='message_edit_topic_propagate' style='display:none;'>
                    <option selected="selected" value="change_later"> {{t "Change later messages to this topic" }}</option>
                    <option value="change_one"> {{t "Change only this message topic" }}</option>
                    <option value="change_all"> {{t "Change previous and following messages to this topic" }}</option>
                </select>
            </div>
        </div>
    </div>
    {{/if}}
    <div class="control-group no-margin">
        <div class="controls edit-controls">
            {{> copy_message_button message_id=this.message_id}}
            <textarea class="message_edit_content" maxlength="10000" id="message_edit_content_{{message_id}}">{{content}}</textarea>
            <div class="scrolling_list preview_message_area" id="preview_message_area_{{message_id}}" style="display:none;">
                <div id="markdown_preview_spinner_{{message_id}}"></div>
                <div id="preview_content_{{message_id}}" class="preview_content rendered_markdown"></div>
            </div>
        </div>
    </div>
    <div class="control-group action-buttons">
        <div class="message_edit_spinner"></div>
        <div class="controls edit-controls">
            {{#if is_editable}}
                <button type="button" class="button small rounded sea-green message_edit_save">{{t "Save" }}</button>
                <button type="button" class="button small rounded message_edit_cancel">{{t "Cancel" }}</button>
                {{#if is_content_editable}}
                <div class="message-edit-feature-group">
                    <input type="file" id="message_edit_file_input_{{message_id}}" class="notvisible pull-left" multiple />
                    {{#if file_upload_enabled}}
                    <a role="button" tabindex=0 class="message-control-button fa fa-paperclip notdisplayed" aria-label="{{t "Attach files" }}" id="attach_files_{{message_id}}" title="{{t "Attach files" }}"></a>
                    {{/if}}
                    <a role="button" tabindex=0 id="markdown_preview_{{message_id}}" class="message-control-button fa fa-eye" aria-label="{{t 'Preview' }}" title="{{t 'Preview' }}"></a>
                    <a role="button" tabindex=0 id="undo_markdown_preview_{{message_id}}" class="message-control-button fa fa-edit" aria-label="{{t 'Write' }}" style="display:none;" title="{{t 'Write' }}"></a>
                    {{#if show_video_chat_button}}
                    <a role="button" tabindex=0 class="message-control-button fa fa-video-camera video_link" aria-label="{{t "Add video call" }}" data-message-id="{{message_id}}" title="{{t "Add video call" }}"></a>
                    {{/if}}
                    <a role="button" tabindex=0 class="message-control-button fa fa-smile-o" aria-label="{{t 'Add emoji' }}" id="emoji_map" data-message-id="{{message_id}}" title="{{t 'Add emoji' }}"></a>
                    {{#if giphy_api_available }}
                    <a role="button" class="message-control-button" aria-label="{{t 'Add GIF' }}" id="compose_box_giphy_grid" title="{{t 'Add GIF' }}">
                        <img class="compose_giphy_logo" tabindex=0 src="/static/images/GIPHY_logo.png" data-message-id="{{message_id}}">
                    </a>
                    {{/if}}
                    <a role="button" tabindex=0 class="message-control-link" data-overlay-trigger="message-formatting" >{{t 'Help' }}</a>
                </div>
                {{/if}}
            {{else}}
                <button type="button" class="button small rounded message_edit_close">{{t "Close" }}</button>
            {{/if}}
            {{#if has_been_editable}}
            <div class="message-edit-timer-control-group">
                <span class="message_edit_countdown_timer"></span>
                <span><i id="message_edit_tooltip" class="tippy-zulip-tooltip message_edit_tooltip fa fa-question-circle" aria-hidden="true" data-tippy-content="{{#tr}}This organization is configured to restrict editing of message content to {minutes_to_edit} minutes after it is sent.{{/tr}}"></i>
                </span>
            </div>
            {{/if}}
        </div>
    </div>
    <div class="alert alert-error edit_error hide"></div>
</form>
